package algorithm.h23d_p17;

import java.util.Arrays;
import java.util.Random;
//随机生成一个矩阵 并进行测试
public class RandomMatrixGenerator {
    public static int[][] generateRandomMatrix(int rows, int cols) {
        int[][] matrix = new int[rows][cols];
        Random random = new Random();

        for (int i = 0; i < rows; i++) {
            for (int j = 0; j < cols; j++) {
                matrix[i][j] = random.nextInt(2);  // 生成随机的 0 或 1
            }
        }

        return matrix;
    }

    public static void printMatrix(int[][] matrix) {
        System.out.println("Random Matrix:");
        for (int[] row : matrix) {
            System.out.println(Arrays.toString(row));
        }
    }

    public static int[][] start(int rows ,int cols) {

        int[][] randomMatrix = generateRandomMatrix(rows, cols);

        printMatrix(randomMatrix);
        return randomMatrix;
    }
}
